<?php if (!defined("_ECRIRE_INC_VERSION")) return; if (class_exists('AlohacartOrderProductModel')) return;
/**
 * Aloha Cart
 *
 * @author     Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com)
 * @license    GNU/GPL
 * @package    plugins
 * @subpackage alohacart
 * @copyright  (c) Aleksey Yaroshchuk 2011-2012
 * @link       http://www.spip-contrib.net/AlohaCart
 */

include_spip('classes/pdk_model');
/**
 *  Order Class
 *  This is alohacart order product model
 *
 *  @author Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com)
 */
class AlohacartOrderProductModel extends pdk_Model {
    
    private $order_mdl;
    
    public function __construct() {
        parent::__construct();
        $this->config_model();
        
        //$this->order_mdl = pdk_load_class('AlohacartOrderModel','classes');        
    }
    
    function config_model() {
        // Define main table:
        $this->main_table = 'spip_alohacart_orders_products';
        
        // Define primary key:
        $this->primary_key = 'id_order_product';
        
        // Define main table fields:
        $this->main_fields['id_order_product'] = 'id_order_product';
        $this->main_fields['id_order'] = 'id_order'; 
        $this->main_fields['id_article'] = 'id_article';
        $this->main_fields['sku'] = 'sku';        
        $this->main_fields['titre'] = 'titre';
        $this->main_fields['quantity'] = 'quantity';
        $this->main_fields['price'] = 'price';
        $this->main_fields['total_price'] = 'total_price';
        $this->main_fields['written_off'] = 'written_off';
                    
                                                                                 
         // Define validation rules:
         $this->validation->set_rules( 
            array(
               array(
                     'field'   => 'id_order',
                     'label'   => 'ID order',
                     'rules'   => 'required'
                  )
            )
         );                                       
    }
    
    // Define test data
    public $test_data = array(
        array('id_order_product'=>1,'id_order'=>1,'id_article'=>1, 'sku'=>'11111','titre'=>'Test article 1', 'quantity'=>1, 'price'=>'90', 'total_price'=>90, 'written_off'=>0),
        array('id_order_product'=>2,'id_order'=>2,'id_article'=>2, 'sku'=>'22222','titre'=>'Test article 2', 'quantity'=>2, 'price'=>'80', 'total_price'=>160,'written_off'=>0),
        array('id_order_product'=>3,'id_order'=>3,'id_article'=>3, 'sku'=>'33333','titre'=>'Test article 3', 'quantity'=>3, 'price'=>'70', 'total_price'=>210,'written_off'=>1),
        array('id_order_product'=>4,'id_order'=>4,'id_article'=>4, 'sku'=>'44444','titre'=>'Test article 4', 'quantity'=>4, 'price'=>'60', 'total_price'=>240,'written_off'=>1),
    );
}
?>